package org.lxy.controller;

import org.lxy.domain.RecycleGoodsEntity;
import org.lxy.service.RecycleGoodsService;
import org.lxy.utils.CoreUtils;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

/**
 * @author 卢心怡
 */
@Controller
public class IndexController extends BaseController{

    @RequestMapping("shangmenhuishou")
    public ModelAndView onSiteRecycle(){
        return new ModelAndView("/jsp/shangmenhuishou");
    }

    @RequestMapping("login")
    public ModelAndView login(String username,String password){
        ModelAndView modelAndView = new ModelAndView("/jsp/Login");
        modelAndView.addObject("username", username);
        modelAndView.addObject("password", password);
        return modelAndView;
    }


    @RequestMapping("register")
    public ModelAndView register(){
        return new ModelAndView("/jsp/register");
    }


    @RequestMapping("index")
    public ModelAndView index(){
        return new ModelAndView("/jsp/index");
    }

    @RequestMapping("loginresult")
    public ModelAndView loginresult(){
        ModelAndView modelAndView = new ModelAndView("/jsp/loginresult");
        return modelAndView;
    }


    @RequestMapping("wupinhuishouresult")
    public ModelAndView wupinhuishouresult(){
        ModelAndView modelAndView = new ModelAndView("/jsp/wupinhuishouresult");
        return modelAndView;
    }



    @RequestMapping("changepwd")
    public ModelAndView changepwd(){
        ModelAndView modelAndView = new ModelAndView("/jsp/changepwd");
        return modelAndView;
    }

    @RequestMapping("changepwdresult")
    public ModelAndView changepwdresult(){
        return new ModelAndView("/jsp/changepwdresult");
    }



    @RequestMapping("home")
    public ModelAndView home(){
        return new ModelAndView("/jsp/Home");
    }

    @RequestMapping("logout")
    public ModelAndView logout(){
        return new ModelAndView("/jsp/Logout");
    }

    @RequestMapping("zixunlist")
    public ModelAndView zixunlist(){
        return new ModelAndView("/jsp/zixunlist");
    }

    @RequestMapping("zixundetail")
    public ModelAndView zixundetail(){
        return new ModelAndView("/jsp/zixundetail");
    }

    @RequestMapping("huishouwulist")
    public ModelAndView huishouwulist(){
        return new ModelAndView("/jsp/huishouwulist");
    }


    @RequestMapping("huishoudianhuishou")
    public ModelAndView huishoudianhuishou(){
        return new ModelAndView("/jsp/huishoudianhuishou");
    }

    @RequestMapping("wodeduihuanwu")
    public ModelAndView wodeduihuanwu(){
        return new ModelAndView("/jsp/wodeduihuanwu");
    }

    @RequestMapping("wodejuanzengwu")
    public ModelAndView wodejuanzengwu(){
        return new ModelAndView("/jsp/wodejuanzengwu");
    }

    @RequestMapping("/huishouwupin/wupinshenhe")
    @ResponseBody
    public Integer wupinshenhe(String ids,String type){
        RecycleGoodsService service = CoreUtils.recycleGoodsService;
        for (String id : ids.split(",")) {
            RecycleGoodsEntity entity = service.getById(Integer.parseInt(id));
            entity.setStatus(type.equals("1")?"审核通过":"审核不通过");
            service.updateById(entity);
        }
        return 1;
    }

    @RequestMapping("/huishouwupin/duihuan")
    public ModelAndView duihuan(Integer ID){
        return new ModelAndView("/huishouwupin/duihuan");
    }


    @RequestMapping("/duihuanresult")
    public ModelAndView duihuanresult(){
        return new ModelAndView("/jsp/duihuanresult");
    }


    @RequestMapping("/huishouwupin/duihuanresult")
    public ModelAndView huishouwupinDuihuanresult(){
        return new ModelAndView("/huishouwupin/duihuanresult");
    }


    @RequestMapping("/wupinleixing/wupinleixingEdit")
    public ModelAndView wupinleixingWupinleixingEdit(){
        return new ModelAndView("/wupinleixing/wupinleixingEdit");
    }


    @RequestMapping("/huishoudian/huishoudianEdit")
    public ModelAndView huishoudianHuishoudianEdit(){
        return new ModelAndView("/huishoudian/huishoudianEdit");
    }


    @RequestMapping("/userinfo/userinfoEdit")
    public ModelAndView userinfoUserinfoEdit(){
        return new ModelAndView("/userinfo/userinfoEdit");
    }



    @RequestMapping("/zixun/tuisong")
    public ModelAndView zixunTuisong(){
        return new ModelAndView("/zixun/tuisong");
    }
    @RequestMapping("/checkpassword")
    public ModelAndView checkpassword(){
        return new ModelAndView("/jsp/checkpassword");
    }






}
